package com.superjson.showpro.entity;

import com.superjson.showpro.base.BaseObj;
import com.beantools.annotation.NotNull;
import com.superjson.showpro.shared.enums.RequestMethodEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

import java.io.Serializable;

import static com.superjson.showpro.shared.enums.RequestMethodEnum.REQUEST_METHOD_GET;

/**
 * Created By zby on 20:37 2019/5/28
 * 文章列表类，比如API中的左列表
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "sp_article_catalog")
@NotNull(notNull = {"content", "name"})
public class ArticleCatalog extends BaseObj implements Serializable{


    private static final long serialVersionUID = -8343625974463999115L;
    /**
     * 父目录；顶层为null
     */
    @ManyToOne
    @JoinColumn(name = "parent_id")
    private ArticleCatalog parent;

    /**
     * 目录的全路径
     */
    @Column(name = "full_id_path", length = 100)
    private String fullIdPath;

    /**
     * 排序
     */
    @Column(name = "sort")
    private Integer sort;

    /**
     * 该目录下的内容
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "content", columnDefinition = "LongText")
    private String content;


    /**
     * 目录名称
     */
    @Column(name = "name")
    private String name;


    /**
     * 请求方法
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "request_method")
    private RequestMethodEnum requestMethod = REQUEST_METHOD_GET;


}